﻿using MediatR;
using T_vehicle.API.Application.Command.MaintenanceCommand;
using T_vehicle.Infrastructure.Interfacec;

namespace T_vehicle.API.Application.CommandHandlers.MaintenanceCommandHandlers
{
    public class DelMaintenanceCommandHandlers:IRequestHandler<DelMaintenanceCommand,int>
    {
        private readonly IMaintenanceRepository maintenanceRepository;

        public DelMaintenanceCommandHandlers(IMaintenanceRepository maintenanceRepository)
        {
            this.maintenanceRepository = maintenanceRepository;
        }

        public async Task<int> Handle(DelMaintenanceCommand request, CancellationToken cancellationToken)
        {
            var list = await maintenanceRepository.GetModelAsync(request.MaintenanceId);
            list.IsDel = true;
            var res = await maintenanceRepository.UpdateAsync(list);
            return res;
        }
    }
}
